#pragma once

#include "../umlmodel_global.h"

#include <memory>
#include <vector>

#include "NamedElement.h"
#include "RedefinableElement.h"
#include "TemplateSignature.h"

using std::make_shared;
using std::shared_ptr;
using std::vector;

namespace uml {
class Classifier;
class RedefinableElement;
class TemplateParameter;

/// <summary>
/// RedefinableTemplateSignature
/// A RedefinableTemplateSignature supports the addition of formal template
/// parameters in a specialization of a template classifier.
/// </summary>
class UMLMODEL_EXPORT RedefinableTemplateSignature : public NamedElement, public RedefinableElement, public TemplateSignature {

public: // Constructors and destructors
    explicit RedefinableTemplateSignature(const QString& umlType="uml::RedefinableTemplateSignature");

public: // JsonSerializable override
    void fromJson(const QJsonObject& json, QStringList& errorList) override;
    void toJson(QJsonObject& json) override;

public: // Methods
    /// <summary>
    /// isConsistentWith
    /// The query isConsistentWith() specifies, for any two
    /// RedefinableTemplateSignatures in a context in which redefinition is possible,
    /// whether redefinition would be logically consistent. A redefining template
    /// signature is always consistent with a redefined template signature, as
    /// redefinition only adds new formal parameters.
    /// </summary>
    bool isConsistentWith(shared_ptr<RedefinableElement> redefiningElement) const override;

public: // Properties
    /// <summary>
    /// classifier getter
    /// The Classifier that owns this RedefinableTemplateSignature.
    /// </summary>
    shared_ptr<Classifier> classifier() const;

    /// <summary>
    /// classifier setter
    /// The Classifier that owns this RedefinableTemplateSignature.
    /// </summary>
    void setClassifier(shared_ptr<Classifier> value);

    /// <summary>
    /// extendedSignatures getter
    /// The signatures extended by this RedefinableTemplateSignature.
    /// </summary>
    vector<shared_ptr<RedefinableTemplateSignature>>& extendedSignatures();

    /// <summary>
    /// inheritedParameters getter
    /// The formal template parameters of the extended signatures.
    /// </summary>
    vector<shared_ptr<TemplateParameter>>& inheritedParameters();

private: // Fields
    /// <summary>
    /// classifier
    /// The Classifier that owns this RedefinableTemplateSignature.
    /// </summary>
    shared_ptr<Classifier> classifier_;

    /// <summary>
    /// extendedSignatures
    /// The signatures extended by this RedefinableTemplateSignature.
    /// </summary>
    vector<shared_ptr<RedefinableTemplateSignature>> extendedSignatures_;

    /// <summary>
    /// inheritedParameters
    /// The formal template parameters of the extended signatures.
    /// </summary>
    vector<shared_ptr<TemplateParameter>> inheritedParameters_;

};

} // namespace uml
